#include "ImageSettings.h"

ImageSettingsWidget::ImageSettingsWidget(QWidget* parent) : QWidget( parent )
{
	ui.setupUi(this);

	connect(ui.bloomSamplesSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( dataChanged() ) );
	connect(ui.bloomAmmountSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( dataChanged() ) );
	connect(ui.bloomDecaySpinBox, SIGNAL( valueChanged(double) ), this, SLOT( dataChanged() ) );
	connect(ui.gammaSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( dataChanged() ) );
	connect(ui.contrastSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( dataChanged() ) );
	connect(ui.exposureSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( dataChanged() ) );
	connect(ui.cameraFOVSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( dataChanged() ) );
	connect(ui.bloomGroupBox, SIGNAL( toggled(bool) ), this, SLOT( dataChanged() ) );
}

ImageSettingsWidget::~ImageSettingsWidget()
{
	
}

void ImageSettingsWidget::dataChanged()
{
	int  bloomSamples = ui.bloomSamplesSpinBox->value();
	float bloomAmmount = ui.bloomAmmountSpinBox->value();
	float bloomDecay = ui.bloomDecaySpinBox->value();
	if(!ui.bloomGroupBox->isChecked())
	{
		bloomAmmount=0.0;
		bloomSamples = 0;
	}
	slotsdata::BloomProperties bloom(bloomSamples,bloomAmmount,bloomDecay);

	float gamma = ui.gammaSpinBox->value();
	float contrast = ui.contrastSpinBox->value();
	float exposure = ui.exposureSpinBox->value();
	float fov = ui.cameraFOVSpinBox->value();
	slotsdata::ImageProperties properties(gamma, contrast,exposure,fov,bloom);

	emit(imageSettingsChanged(properties));
}
